{% extends "base.volt" %}
{% block pageHeader %}
    {{ stylesheet_link("/assets/manage/css/tabstyle.css", false) }}
    {{ stylesheet_link("/libs/bootstrap-daterangepicker/daterangepicker.css", false) }}
{% endblock %}
{% block pageFooter%}
	{{ javascript_include("/libs/bootstrap-daterangepicker/moment.min.js", false) }}
    {{ javascript_include("/libs/bootstrap-daterangepicker/daterangepicker.js", false) }}
    {{ javascript_include("/assets/manage/js/activity/list.js", false) }}
{% endblock %}

{% block content %}
    {{ partial("module/left_activity") }}
    <div class="col-xs-10">
        <ol class="breadcrumb">
            <li>活动管理</li>
            <li class="active">活动列表</li>
        </ol>
        
        <div class="commtable">
			<ul>
    			<li {% if activity_state == 1 %} class="hover" {% endif %}><a href="{{ url.get('activity/list',['activity_state':1]) }}"> 已发布</a></li>
        		<li {% if activity_state == 0 %} class="hover" {% endif %}><a href="{{ url.get('activity/list',['activity_state':0]) }}"> 待发布</a></li>
        		<li {% if activity_state == 2 %} class="hover" {% endif %}><a href="{{ url.get('activity/list',['activity_state':2]) }}"> 已结束</a></li>
    		</ul>
		</div>
		<div style="clear:both;"></div>
        <div class="panel panel-default">
            <div class="panel-body">
                <form class="form-inline" role="form" action="" method="get">
                <input type="hidden" name="activity_state" value="{{activity_state}}">
                    <div class="form-group">
                        <div class="input-group">
                        	<label class="input-group-addon" for="">标题:</label>
                        	<input class="form-control" type="text" name="activity_title" id="" value="{{activity_title}}" />
                    	</div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <label class="input-group-addon">城市</label>
                            <select class="form-control" name="filterCity" id="filterCity">
                            <option value="-10000" {{ filterCity == -10000 ? 'selected="selected"' : '' }}>请选择</option>
                                <option value="0" {{ filterCity == 0 ? 'selected="selected"' : '' }}>全国</option>
                                {% for oc in openCity %}
                                    <option value="{{ oc.city_id }}" {{ filterCity == oc.city_id ? 'selected="selected"' : '' }} >{{ oc.city_name|e }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                        	<label class="input-group-addon" for="">活动周期:</label>
                        	<input class="form-control" type="text" id="activity_time" name="activity_time" value="{{activity_time}}" style="width: 400px;" readonly>
                    	</div>
                    </div>
                    <div class="form-group">
                        <button type="submit" class="btn btn-primary"><i class="fa fa-filter"></i> 搜 索</button>
                    </div>
                </form>
            </div>
        </div>

        <table class="table table-hover">
            <thead>
            <tr>
                <th style="width: 60px;">ID</th>
                <th style="width: 120px;">城市</th>
                <th style="width: 200px;">标题</th>
                <th style="width: 80px;">状态</th>
                {%if activity_state == 1 or activity_state == 2%}
                <th style="width: 160px;">开始时间</th>
                <th style="width: 160px;">结束时间</th>
                {%endif%}
                <th style="width: 160px;">发布人</th>
                <!--<th style="width: 160px;">活动位置</th>-->
                <th style="width: 200px;">操作</th>
            </tr>
            </thead>
            {% for d in data %}
                <tr>
                    <td>{{ d['activity_id'] }}</td>
                    <td>
                    {%if d['city_name'] == null%}
                    	全国
                    {%else%}
                    	{{ d['city_name']|e }}
                    {%endif%}
                    </td>
                    <td>{{ d['activity_title']|e }}</td>
                    <!-- <td>
                    {%if d.activity_state == '1' and d.stime > 0 %}
                   		 未到开始时间 
                    {%elseif d.activity_state == '0'%}
                    	待发布
                    {%elseif d.activity_state == '1'%}
                    	已发布
                    {%elseif d.activity_state == '2'%}
                    	已结束
                    {%endif%}
                    </td> -->
                    <td d="{{ d.ts }}">
                    {%if d['ts'] <= 0 or d['activity_state'] == '2'%}
                    	已结束
                    {%elseif d['activity_state'] == '1' and d['stime'] > 0 %}
                    	<!-- 未到开始时间 --> 
                    {%elseif d['activity_state'] == '0'%}
                    	待发布
                    {%elseif d['activity_state'] == '1'%}
                    	已开始
                    <!-- {%elseif d.activity_state == '2'%}
                    	已结束2 -->
                    {%endif%}
                    <!-- {{ d.ts > 0 ? ActivityStateToStr(d.activity_state) : '已结束' }} -->
                    	                                                         
                    </td>
                    {%if activity_state == 1 or activity_state == 2%}
                    <td>{{ d['activity_start_time'] }}</td>
                    <td>{{ d['activity_end_time'] }}</td>
                    {%endif%}
                    <td>{{ d['create_user'] }}</td>
                    <!--<td>
                    {{d.posion_banner}}
                    	&lt;!&ndash; {%if d.posion_banner == 1%}通栏一{%endif%}
                    	{%if d.posion_banner == 2%}通栏二{%endif%}
                    	{%if d.posion_banner == 3%}通栏三{%endif%}
                    	{%if d.posion_banner == 4%}通栏四{%endif%}
                    	{%if d.posion_banner == 5%}底部左边广告{%endif%}
                    	{%if d.posion_banner == 6%}底部右上广告{%endif%}
                    	{%if d.posion_banner == 7%}底部右下广告{%endif%} &ndash;&gt;
                    </td>-->
                    
                    <td>
                        <div class="dropdown">
                            <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu{{ d['activity_id'] }}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"><i class="fa fa-cogs"></i> 操作 <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="dropdownMenu{{ d['activity_id'] }}">
                            	{% if d['activity_state'] == 1 and d['ts'] > 0 or d['activity_state'] == 0%}
                                <li><a href="/frontend/share/activityPreview?id={{ d['activity_id'] }}" target="_blank"><i class="fa fa-eye fa-fw"></i> 预览</a></li>
                                {% endif %}
                                {% if d['activity_state'] == 1 or d['activity_state'] == 2%}
                                <li role="separator" class="divider"></li>
                                <li><a href="{{ url.get('activity/commentList', ['id': d['activity_id']]) }}" dtitle="{{ d['activity_title']|escape_attr }}" ><i class="fa fa-puzzle-piece fa-fw"></i> 查看回复</a></li>
                                {% endif %}
                                <li role="separator" class="divider"></li>
                                <li><a href="{{ url.get('activity/update', ['id': d['activity_id']]) }}"><i class="fa fa-pencil fa-fw"></i> 编辑</a></li>
                                {% if d['activity_state'] == 0 or d['activity_state'] == 2 or d['ts'] <= 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d['activity_id'] }}" dstate="1" dtitle="发布活动" class="but_set_state2" durl="{{ url.get('activity/setState',['id': d['activity_id'],'state':1])}}"><i class="fa fa-paper-plane-o fa-fw"></i> 发 布</a></li>
                                {% endif %}
                                {% if d['activity_state'] == 1 and d['ts'] > 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d['activity_id'] }}" dstate="2" class="but_set_state" durl="{{ url.get('activity/setState') }}"><i class="fa fa-hourglass-end fa-fw"></i> 结束</a></li>
                                {% endif %}
                                <!-- {% if d.activity_state == 0 and d.ts > 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d.activity_id }}" dstate="1" class="but_set_state" durl="{{ url.get('activity/setState') }}"><i class="fa fa-paper-plane-o fa-fw"></i> 发 布</a></li>
                                {% endif %}
                                {% if d.activity_state == 1 and d.ts > 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d.activity_id }}" dstate="2" class="but_set_state" durl="{{ url.get('activity/setState') }}"><i class="fa fa-hourglass-end fa-fw"></i> 结束</a></li>
                                {% endif %}
                                {% if d.activity_state == -1 and d.ts > 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d.activity_id }}" dstate="0" class="but_set_state" durl="{{ url.get('activity/setState') }}"><i class="fa fa-reply fa-fw"></i> 恢 复</a></li>
                                {% endif %}
                                {% if d.activity_state == 2 or d.ts <= 0 %}
                                    <li><a href="javascript:void(0)" did="{{ d.activity_id }}" dstate="-1" class="but_set_state" durl="{{ url.get('activity/setState') }}"><i class="fa fa-trash-o fa-fw"></i> 删 除</a></li>
                                {% endif %} -->
                            </ul>
                        </div>
                    </td>
                   
                </tr>
            {% endfor %}
        </table>

        {{ this.tagNav.page(
        page,
        total,
        limit,
        url.get('activity/list', [
        'filterCity': filterCity,
        'activity_title':activity_title,
        'activity_state':activity_state,
        'activity_time':activity_time,
        'page': '__PAGE__'
        ]
        )) }}

    </div>
{% endblock %}